package com._21cn.cms.resource.utils;

import com._21cn.cms.common.Constants;
import com._21cn.framework.utils.StringUtil;

/**
 * Created by Thinkpad on 2017/4/1.
 */
public class PictureUtil {

    public static String getHashCodeFromUrl( String picUrl ){
        if( !isInPictureLib( picUrl ) )
            return "";
        String hashcode  = picUrl.substring( picUrl.lastIndexOf( "/" )+1 ).split( "\\." )[0];
        if( StringUtil.isEmpty(hashcode) || hashcode.length() != 32 )
            return "";
        return hashcode;
    }

    public static boolean isInPictureLib(String picUrl) {
        if (StringUtil.isEmpty(picUrl))
            return false;
        return picUrl.contains(Constants.DEFAULT_IMAGE_HOST) ;
    }
}
